/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edi.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
import org.joda.time.DateTime;
import org.springframework.data.domain.Auditable;

/**
 *
 * @author Kamil
 */

@Entity
@Table(name = "T_DOC_TYPES")
@Where(clause = "DCT_AUDIT_RD IS NULL")
public class DocTypeEntity implements Auditable<Long, Long>, Serializable {

    private static final long serialVersionUID = 4169905761804555798L;

    @Id
    @SequenceGenerator(name = "doc_types_sequence", sequenceName = "S_DCT_ID", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "doc_types_sequence")
    @Column(name = "DCT_ID")
    private Long dctId;

    @Column(length = 5, nullable = false, name = "DCT_EXTENSION")
    private String dctExtension;

    @Column(length = 50, nullable = false, name = "DCT_NAME")
    private String dctName;

    @Column(name = "DCT_ICON")
    private byte[] dctIcon;
    
    
    @Column(name = "DCT_AUDIT_CD")
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime") 
    private DateTime createdDate;
    
    @Column(name = "DCT_AUDIT_CU")
    private Long createUser;
    
    @Column(name = "DCT_AUDIT_MD")
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime") 
    private DateTime modifiedDate;
    
    @Column(name = "DCT_AUDIT_MU")
    private Long modifiedUser;
    
    @Column(name = "DCT_AUDIT_RD")
    @SuppressWarnings("unused")
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime") 
    private DateTime removeDate;
    
    @Column(name = "DCT_AUDIT_RU")
    @SuppressWarnings("unused")
    private Long removeUser;

    public Long getDctId() {
        return dctId;
    }

    public String getDctExtension() {
        return dctExtension;
    }

    public void setDctExtension(String dctExtension) {
        this.dctExtension = dctExtension;
    }

    public String getDctName() {
        return dctName;
    }

    public void setDctName(String dctName) {
        this.dctName = dctName;
    }

    public byte[] getDctIcon() {
        return dctIcon;
    }

    public void setDctIcon(byte[] dctIcon) {
        this.dctIcon = dctIcon;
    }

    @Override
    public boolean isNew() {
        return (dctId == null);
    }
    
     @Override
     public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
     }

     @Override
     public boolean equals(Object o) {
        return EqualsBuilder.reflectionEquals(this, o);
     }

     @Override
     public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
     }
    

    @Override
    public Long getCreatedBy() {
      return createUser;
    }
    
    @Override
    public void setCreatedBy(Long u) {
        createUser = u;
    }

    @Override
    public org.joda.time.DateTime getCreatedDate() {
    return createdDate;
    }

    @Override
    public void setCreatedDate(org.joda.time.DateTime dt) {
       createdDate = dt;
    }

    @Override
    public Long getLastModifiedBy() {
        return modifiedUser;
    }

    @Override
    public void setLastModifiedBy(Long u) {
       modifiedUser = u;
    }

    @Override
    public org.joda.time.DateTime getLastModifiedDate() {
        return modifiedDate;
    }

    @Override
    public void setLastModifiedDate(org.joda.time.DateTime dt) {
        modifiedDate = dt;
    }
    public void setRemoveDate(org.joda.time.DateTime dt) {
        removeDate = dt;
    }
           
    public void setRemovedBy(Long u) {
       removeUser = u;
    }

    @Override
    public Long getId() {
        return dctId;
    }
}
